home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ahoy 1988 April
/
Ahoy_Magazine_88-04_1988_Double_L.d64
/
Random Walk 2
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-10-26
|
947b
|
36 lines
1 rem ================================
2 rem commodares problem #48-2
3 rem random walk
4 rem solution by
5 rem paul sobolik
6 rem ====== c-64 only ==============
10 c0=49152
20 for x=0 to 4*8
30 : read a
40 : poke c0+x,a
50 next
60 for x=0 to 8:poke c0+32*8+x,0:next
70 v1=peek(56576):v2=peek(53272):os=peek(648)
80 poke 53272,16:poke 56576,v1 and 252:poke 648,(c0+1024)/256
90 print"[147]";
100 data 24,60,126,255,24,24,24,24: rem up arrow
110 data 24,24,24,24,255,126,60,24: rem down arrow
120 data 16,48,112,255,255,112,48,16: rem left arrow
130 data 8,12,14,255,255,14,12,8,0: rem right arrow
140 xp = 211:yp = 214
150 dim a$(4)
160 a$(0)="@[157][145]": rem up
170 a$(1)="a[157]": rem down
180 a$(2)="c[157][157]": rem left
190 a$(3)="b" : rem right
200 x=int(rnd(1)*4)
210 cx=peek(xp)
220 cy=peek(yp)
230 if x=0 and cy=0 then 280
240 if x=1 and cy=24 then 280
250 if x=2 and (cx=0 or cx=40) then 280
260 if x=3 and (cx=39 or cx=79) then 280
270 printa$(x);
280 geta$:ifa$=""then200
290 poke 648,os:poke53272,v2:poke 56576,v1